<?php echo $header; ?>
<div id="content">
	<?php if ($error_warning) { ?>
	  <div class="warning" style="margin: 45px 0 8px;"><?php echo $error_warning; ?></div>
  	<?php } ?>
	<?php if ($success) { ?>
	  <div class="success"><?php echo $success; ?></div>
	  <div class="box">
		<div class="heading"><h1><img src="view/image/admin_theme/base5builder_impulsepro/icon-settings-large.png" alt="" /> <?php echo $heading_title; ?></h1>
	    </div>
	    <div class="content">
	    	<table class="form">
	    		<tr><td><?php echo $text_visit ?></td><td><a href="<?php echo $config_url ?>" target="_blank"><?php echo $config_url ?></a></td></tr>
	    		<tr><td><?php echo $text_login ?></td><td><a href="<?php echo $config_url.'admin/' ?>" target="_blank"><?php echo $config_url.'admin/' ?></a></td></tr>
	    		<tr><td><?php echo $text_username ?></td><td><?php echo $username ?></td></tr>
	    		<tr><td><?php echo $text_password ?></td><td>********</td></tr>
	    	</table>
	    </div>
	   </div>
	 <?php }else{ ?>
	<div class="box">
		<div class="heading"><h1><img src="view/image/admin_theme/base5builder_impulsepro/icon-settings-large.png" alt="" /> <?php echo $heading_title; ?></h1>
	      <div class="buttons"><a onclick="$('#form').submit();" class="button save"><?php echo $button_save; ?></a><a href="<?php echo $cancel; ?>" class="button cancel"><?php echo $button_cancel; ?></a></div>
	    </div>
		<div class="content">
			<div id="tabs" class="htabs"><a href="#tab-general"><?php echo $tab_general; ?></a><a href="#tab-store"><?php echo $tab_store; ?></a>
	      </div>
	      <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
	        <div id="tab-general">
	        	<table class="form">
		          <tr>
		            <td><span class="required">*</span> <?php echo $entry_username; ?></td>
		            <td><input type="text" name="username" value="<?php echo $username; ?>" />
		              <?php if ($error_username) { ?>
		              <span class="error"><?php echo $error_username; ?></span>
		              <?php } ?></td>
		          </tr>
		          <tr>
		            <td><span class="required">*</span> <?php echo $entry_firstname; ?></td>
		            <td><input type="text" name="firstname" value="<?php echo $firstname; ?>" />
		              <?php if ($error_firstname) { ?>
		              <span class="error"><?php echo $error_firstname; ?></span>
		              <?php } ?></td>
		          </tr>
		          <tr>
		            <td><span class="required">*</span> <?php echo $entry_lastname; ?></td>
		            <td><input type="text" name="lastname" value="<?php echo $lastname; ?>" />
		              <?php if ($error_lastname) { ?>
		              <span class="error"><?php echo $error_lastname; ?></span>
		              <?php } ?></td>
		          </tr>
		          <tr>
		            <td><?php echo $entry_email; ?></td>
		            <td><input type="text" name="email" value="<?php echo $email; ?>" /></td>
		          </tr>
		          <tr>
		            <td><?php echo $entry_password; ?></td>
		            <td><input type="password" name="password" value="<?php echo $password; ?>"  />
		              <?php if ($error_password) { ?>
		              <span class="error"><?php echo $error_password; ?></span>
		              <?php  } ?></td>
		          </tr>
		          <tr>
		            <td><?php echo $entry_confirm; ?></td>
		            <td><input type="password" name="confirm" value="<?php echo $confirm; ?>" />
		              <?php if ($error_confirm) { ?>
		              <span class="error"><?php echo $error_confirm; ?></span>
		              <?php  } ?></td>
		          </tr>
		        </table>
	        </div>
	        <div id="tab-store">
	          <table class="form">
	          	<tr>
	              <td><span class="required">*</span> <?php echo $entry_name; ?></td>
	              <td><input type="text" name="config_name" value="<?php echo $config_name; ?>" size="40" />
	                <?php if ($error_name) { ?>
	                <span class="error"><?php echo $error_name; ?></span>
	                <?php } ?></td>
	            </tr>
	            <tr>
	              <td><span class="required">*</span> <?php echo $entry_owner; ?></td>
	              <td><input type="text" name="config_owner" value="<?php echo $config_owner; ?>" size="40" />
	                <?php if ($error_owner) { ?>
	                <span class="error"><?php echo $error_owner; ?></span>
	                <?php } ?></td>
	            </tr>
	            <tr>
	              <td><span class="required">*</span> <?php echo $entry_title; ?></td>
	              <td><input type="text" name="config_title" value="<?php echo $config_title; ?>" />
	                <?php if ($error_title) { ?>
	                <span class="error"><?php echo $error_title; ?></span>
	                <?php } ?></td>
	            </tr>
	            <tr>
	              <td><span class="required">*</span> <?php echo $entry_address; ?></td>
	              <td><textarea name="config_address" cols="40" rows="5"><?php echo $config_address; ?></textarea>
	                <?php if ($error_address) { ?>
	                <span class="error"><?php echo $error_address; ?></span>
	                <?php } ?></td>
	            </tr>
	            <tr>
	              <td><span class="required">*</span> <?php echo $entry_email; ?></td>
	              <td><input type="text" name="config_email" value="<?php echo $config_email; ?>" size="40" />
	                <?php if ($error_email) { ?>
	                <span class="error"><?php echo $error_email; ?></span>
	                <?php } ?></td>
	            </tr>
	            <tr>
	              <td><span class="required">*</span> <?php echo $entry_telephone; ?></td>
	              <td><input type="text" name="config_telephone" value="<?php echo $config_telephone; ?>" />
	                <?php if ($error_telephone) { ?>
	                <span class="error"><?php echo $error_telephone; ?></span>
	                <?php } ?></td>
	            </tr>
	            <tr>
	              <td><?php echo $entry_fax; ?></td>
	              <td><input type="text" name="config_fax" value="<?php echo $config_fax; ?>" /></td>
	            </tr>
	            <tr>
	              <td><?php echo $entry_meta_description; ?></td>
	              <td><textarea name="config_meta_description" cols="40" rows="5"><?php echo $config_meta_description; ?></textarea></td>
	            </tr>
	            <tr>
	              <td><?php echo $entry_country; ?></td>
	              <td><select name="config_country_id">
	                  <?php foreach ($countries as $country) { ?>
	                  <?php if ($country['country_id'] == $config_country_id) { ?>
	                  <option value="<?php echo $country['country_id']; ?>" selected="selected"><?php echo $country['name']; ?></option>
	                  <?php } else { ?>
	                  <option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
	                  <?php } ?>
	                  <?php } ?>
	                </select></td>
	            </tr>
	            <tr>
	              <td><?php echo $entry_zone; ?></td>
	              <td><select name="config_zone_id">
	                </select></td>
	            </tr>
	            <tr>
	              <td><?php echo $entry_language; ?></td>
	              <td><select name="config_language">
	                  <?php foreach ($languages as $language) { ?>
	                  <?php if ($language['code'] == $config_language) { ?>
	                  <option value="<?php echo $language['code']; ?>" selected="selected"><?php echo $language['name']; ?></option>
	                  <?php } else { ?>
	                  <option value="<?php echo $language['code']; ?>"><?php echo $language['name']; ?></option>
	                  <?php } ?>
	                  <?php } ?>
	                </select></td>
	            </tr>
	            <tr>
	              <td><?php echo $entry_currency; ?></td>
	              <td><select name="config_currency">
	                  <?php foreach ($currencies as $currency) { ?>
	                  <?php if ($currency['code'] == $config_currency) { ?>
	                  <option value="<?php echo $currency['code']; ?>" selected="selected"><?php echo $currency['title']; ?></option>
	                  <?php } else { ?>
	                  <option value="<?php echo $currency['code']; ?>"><?php echo $currency['title']; ?></option>
	                  <?php } ?>
	                  <?php } ?>
	                </select></td>
	            </tr>
	          </table>
	        </div>
	      </form>
		</div>
	</div>
	<?php } ?>
</div>
<?php if (!$success) { ?>
<script type="text/javascript"><!--
$('select[name=\'config_country_id\']').bind('change', function() {
	$.ajax({
		url: 'index.php?route=common/home/country&country_id=' + this.value,
		dataType: 'json',
		beforeSend: function() {
			$('select[name=\'country_id\']').after('<span class="wait">&nbsp;<img src="view/image/loading.gif" alt="" /></span>');
		},		
		complete: function() {
			$('.wait').remove();
		},			
		success: function(json) {
			if (json['postcode_required'] == '1') {
				$('#postcode-required').show();
			} else {
				$('#postcode-required').hide();
			}
			
			html = '<option value=""><?php echo $text_select; ?></option>';
			
			if (json['zone'] != '') {
				for (i = 0; i < json['zone'].length; i++) {
        			html += '<option value="' + json['zone'][i]['zone_id'] + '"';
	    			
					if (json['zone'][i]['zone_id'] == '<?php echo $config_zone_id; ?>') {
	      				html += ' selected="selected"';
	    			}
	
	    			html += '>' + json['zone'][i]['name'] + '</option>';
				}
			} else {
				html += '<option value="0" selected="selected"><?php echo $text_none; ?></option>';
			}
			
			$('select[name=\'config_zone_id\']').html(html);
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});
});

$('select[name=\'config_country_id\']').trigger('change');
//--></script> 

<script type="text/javascript"><!--
$('#tabs a').tabs();
//--></script> 
<?php } ?>
<?php echo $footer; ?>